/* import Mock from "mockjs"

// const routes = require('../assets/dynamicRoutes');

// 模拟用户数据
const userList = [
    { id: "001", name: "张三" },
    { id: "002", name: "李四" },
    { id: "003", name: "王五" },
    { id: "004", name: "王六" },
    { id: "005", name: "小明" },
    { id: "006", name: "牛粪" },
    { id: "007", name: "大狗" },
    { id: "008", name: "小猫" },
    { id: "009", name: "小猪" },
    { id: "0010", name: "小虎" },
    { id: "0011", name: "小龙" },
    { id: "0013", name: "小兔" },
    { id: "0014", name: "小兔" },
    { id: "0015", name: "小兔" },
    { id: "0016", name: "小兔" },
    { id: "0017", name: "小兔" },
];

const administratorList = [
    { id: "0018", name: "小兔" },
]


// 添加管理员的方法（抽取出来复用）
function administratorToList(id) {
    userList.forEach((user, index) => {
        if (user.id == id) {
            administratorList.unshift(userList.splice(index, 1)[0]);
        }
    });
}


// 模拟后端将用户成为管理员接口
Mock.mock('/admin/userManage/addAdministrator', 'post', req => {
    const { id } = JSON.parse(req.body);
    administratorToList(id);
    return {
        code: 200,
        data: {},
        msg: '已成为管理员'
    }
})


// 模拟后端批量移入添加管理员接口(简单的批量移入操作，不做异常处理)
Mock.mock('/admin/userManage/addAdministrators', 'post', req => {
    // 接收前端传递的用户id数组
    const { idList } = JSON.parse(req.body);
    idList.forEach((id) => administratorToList(id));
    return {
        code: 200,
        data: {},
        msg: '已成为管理员'
    }
})

// 返回按关键字搜索的管理员列表数据
Mock.mock("/admin/userManage/getAdministratorList", "post", req => {
    const { keyword, pageNum } = JSON.parse(req.body);
    // this.todos.unshift(item);
    const re = new RegExp(`.*${keyword}.*`);
    const list = administratorList.filter((user) => !user.name.search(re));
    // 按分页截取结果集合
    const result = list.slice((pageNum - 1) * 8, pageNum * 8);
    console.log(list.length)
    console.log('总页数：', Math.ceil(list.length / 8));
    return {
        code: 200,
        data: {
            administratorList: result,
            pageInfo: {
                // 总页数
                totalPage: Math.ceil(list.length / 8),
                // 当前页码
                // pageNum: ,
            }
        },
        msg: "搜索成功"
    }
})

// 将一个用户移出管理员名单（方法抽取出来可复用）
function cancelAdminList(id) {
    administratorList.forEach((user, index) => {
        if (user.id == id) {
            userList.unshift(administratorList.splice(index, 1)[0]);
        }
    });
}

// 移出黑名单
Mock.mock("/admin/userManage/cancelAdminListUser", "post", req => {
    const { id } = JSON.parse(req.body);
    cancelAdminList(id);
    console.log(administratorList);
    return {
        code: 200,
        data: {},
        msg: '已移出管理员名单'
    }
})

// 批量移出黑名单
Mock.mock("/admin/userManage/cancelAdminListUsers", "post", req => {
    const { idList } = JSON.parse(req.body);
    idList.forEach((id) => cancelAdminList(id));
    return {
        code: 200,
        data: {},
        msg: '已移出管理员名单'
    }
})

export default {
} */